﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Copy4Backup
{
	/// <summary>
	/// Interaction logic for FilterWindow.xaml
	/// </summary>
	public partial class FilterWindow : Window
	{
		/// <summary>
		/// Gets or sets the filter value.
		/// </summary>
		public string Filter
		{
			get
			{
				return textBoxFilter.Text;
			}
			set
			{
				textBoxFilter.Text = value;
			}
		}
		/// <summary>
		/// Suppress default ctor usage.
		/// </summary>
		private FilterWindow()
		{
		}

		public FilterWindow(bool folderFilter)
		{
			InitializeComponent();

			if (folderFilter)
			{
				Title = "Folder filter";
				label_.Content = "Folder filter";
			}
			else
			{
				Title = "File filter";
				label_.Content = "File filter";
			}
		}

		private void buttonOK_Click(object sender, RoutedEventArgs e)
		{
			if (0 < textBoxFilter.Text.Length)
			{
				DialogResult = true;
				this.Close();
			}
			else
			{
				MessageBox.Show("Empty value is not valid.", Title, MessageBoxButton.OK, MessageBoxImage.Error);
			}
			
		}

		private void buttonCancel_Click(object sender, RoutedEventArgs e)
		{
			DialogResult = false;
			this.Close();
		}

		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			textBoxFilter.Focus();
		}
	}
}
